{extend name="index/base" /}
{block name="body" }
<blockquote class="layui-elem-quote">
	<button  class="layui-btn layui-btn-sm" id="add" data-url="{:url('cate_add')}">
		<i class="layui-icon">&#xe654;</i> 添加分类
	</button>
</blockquote>
<table class="layui-table">
  <thead>
    <tr>
      <th>分类名称</th>
      <th>修改时间</th>
      <th>操作</th>
    </tr> 
  </thead>
  <tbody>
  	{volist name="cate_list" id="vo"}
    <tr>
      <td>{$vo.name}</td>
      <td>{$vo.update_time}</td>
      <td>
      	<div class="layui-btn-group">
		  <a class="layui-btn layui-btn-xs edit" data-url="{:url('cate_edit',['id'=>$vo.id])}" >编辑</a>
		  <a class="layui-btn layui-btn-xs confirm_del" data-url="{:url('cate_del',['id'=>$vo.id])}" >删除</a>
		</div>
      </td>
    </tr>
    {volist name="vo.childlist" id="v2"}
    <tr>
      <td>&nbsp;&nbsp;└{$v2.name}</td>
      <td>{$v2.update_time}</td>
      <td>
      	<div class="layui-btn-group">
		  <a class="layui-btn layui-btn-xs edit" data-url="{:url('cate_edit',['id'=>$v2.id])}" >编辑</a>
		  <a class="layui-btn layui-btn-xs confirm_del" data-url="{:url('cate_del',['id'=>$v2.id])}" >删除</a>
		</div>
      </td>
    </tr>
    {/volist}
    {/volist}
  </tbody>
</table>
{/block}

{block name="script"}
<script>
layui.use(['tool'], function() {
	var $ = layui.$,layer = layui.layer, form = layui.form,table = layui.table,tool = layui.tool;
	//添加
	$(document).on('click','#add,.edit',function(){
	    var url = $(this).data('url'),title = '添加分类';
	    if($(this).hasClass('edit')){
	      url = $(this).data('url');
	      title = '编辑分类';
	    }
	  	layer.open({
	      title:title,
	      type: 2,
	      area: ['50%', '80%'],
	      fixed: false, //不固定
	      maxmin: true,
	      content: url,
	      shade:0,
	      id:'group_add'
	    });
	});
});
</script>
{/block}